package com.ruoyi.manage.service.impl;

import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manage.mapper.SuitManagementMapper;
import com.ruoyi.manage.domain.SuitManagement;
import com.ruoyi.manage.service.ISuitManagementService;

/**
 * 婚纱套系Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-03-01
 */
@Service
public class SuitManagementServiceImpl implements ISuitManagementService 
{
    @Autowired
    private SuitManagementMapper suitManagementMapper;

    /**
     * 查询婚纱套系
     * 
     * @param id 婚纱套系ID
     * @return 婚纱套系
     */
    @Override
    public SuitManagement selectSuitManagementById(Long id)
    {
        SuitManagement suitManagement = suitManagementMapper.selectSuitManagementById(id);
        String imageListOb = suitManagement.getImageList();
        List list = JSONObject.parseObject(imageListOb, List.class);
        suitManagement.setImageListOb(list);
        String clothingImageListOb = suitManagement.getClothingImageList();
        List list1 = JSONObject.parseObject(clothingImageListOb, List.class);
        suitManagement.setClothingImageListOb(list1);
        String coverImageOb = suitManagement.getCoverImage();
        List list2 = JSONObject.parseObject(coverImageOb, List.class);
        suitManagement.setCoverImageOb(list2);
        String siteImageListOb = suitManagement.getSiteImageList();
        List list3 = JSONObject.parseObject(siteImageListOb, List.class);
        suitManagement.setSiteImageListOb(list3);
        return suitManagement;
    }

    /**
     * 查询婚纱套系列表
     * 
     * @param suitManagement 婚纱套系
     * @return 婚纱套系
     */
    @Override
    public List<SuitManagement> selectSuitManagementList(SuitManagement suitManagement)
    {
        return suitManagementMapper.selectSuitManagementList(suitManagement);
    }

    /**
     * 新增婚纱套系
     * 
     * @param suitManagement 婚纱套系
     * @return 结果
     */
    @Override
    public int insertSuitManagement(SuitManagement suitManagement)
    {
        List<String> imageListOb = suitManagement.getImageListOb();
        suitManagement.setImageList(JSONObject.toJSONString(imageListOb));
        List<String> clothingImageListOb = suitManagement.getClothingImageListOb();
        suitManagement.setClothingImageList(JSONObject.toJSONString(clothingImageListOb));
        List<String> coverImageOb = suitManagement.getCoverImageOb();
        suitManagement.setCoverImage(JSONObject.toJSONString(coverImageOb));
        List<String> siteImageListOb = suitManagement.getSiteImageListOb();
        suitManagement.setSiteImageList(JSONObject.toJSONString(siteImageListOb));

        suitManagement.setCreateTime(DateUtils.getNowDate());
        return suitManagementMapper.insertSuitManagement(suitManagement);
    }

    /**
     * 修改婚纱套系
     * 
     * @param suitManagement 婚纱套系
     * @return 结果
     */
    @Override
    public int updateSuitManagement(SuitManagement suitManagement)
    {
        List<String> imageListOb = suitManagement.getImageListOb();
        suitManagement.setImageList(JSONObject.toJSONString(imageListOb));
        List<String> clothingImageListOb = suitManagement.getClothingImageListOb();
        suitManagement.setClothingImageList(JSONObject.toJSONString(clothingImageListOb));
        List<String> coverImageOb = suitManagement.getCoverImageOb();
        suitManagement.setCoverImage(JSONObject.toJSONString(coverImageOb));
        List<String> siteImageListOb = suitManagement.getSiteImageListOb();
        suitManagement.setSiteImageList(JSONObject.toJSONString(siteImageListOb));
        return suitManagementMapper.updateSuitManagement(suitManagement);
    }

    /**
     * 批量删除婚纱套系
     * 
     * @param ids 需要删除的婚纱套系ID
     * @return 结果
     */
    @Override
    public int deleteSuitManagementByIds(Long[] ids)
    {
        return suitManagementMapper.deleteSuitManagementByIds(ids);
    }

    /**
     * 删除婚纱套系信息
     * 
     * @param id 婚纱套系ID
     * @return 结果
     */
    @Override
    public int deleteSuitManagementById(Long id)
    {
        return suitManagementMapper.deleteSuitManagementById(id);
    }
}
